﻿using MagicVilla_API.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;

namespace MagicVilla_API.Data
{
    public class ApplicationDbContext : DbContext
    {
        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
        {


        }

        public DbSet<Villa> Villas { get; set; }
        public DbSet<VillaNumber> VillaNumbers { get; set; }
        public DbSet<LocalUser> LocalUsers { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Villa>().HasData(
                new Villa()
                {
                    Id = 1,
                    Name = "Royal Villa",
                    Details = "This is the Royal Villa",
                    Rate = 200.0,
                    Sqft = 550,
                    Occupancy = 4,
                    ImageUrl = "https://cf.bstatic.com/xdata/images/hotel/max1024x768/518127419.jpg?k=7c223a710a575afb8e74426da930b9598238de324285a6e8cd0eabd5d31ebe97&o=",
                    Amenity = "",
                    CreatedDate = DateTime.Now
                },
                new Villa()
                {
                    Id = 2,
                    Name = "Premium Pool Villa",
                    Details = "This is the Premium Pool Villa",
                    Rate = 300.0,
                    Sqft = 550,
                    Occupancy = 4,
                    ImageUrl = "https://pix10.agoda.net/hotelImages/115/1158987/1158987_16010616210038913309.jpg?ca=6&ce=1&s=1024x768",
                    Amenity = "",
                    CreatedDate = DateTime.Now
                },
                new Villa()
                {
                    Id = 3,
                    Name = "Luxury Pool Villa",
                    Details = "This is the Luxury Pool Villa",
                    Rate = 400.0,
                    Sqft = 750,
                    Occupancy = 4,
                    ImageUrl = "https://statics.dujiabieshu.com/statics/manager/ueditor/php/upload/image/20190918/fee72e01fc44e1db0b94e05ce532c8fe621372.jpg",
                    Amenity = "",
                    CreatedDate = DateTime.Now
                },
                new Villa()
                {
                    Id = 4,
                    Name = "Diamond Villa",
                    Details = "This is the Diamond Villa",
                    Rate = 550.0,
                    Sqft = 900,
                    Occupancy = 4,
                    ImageUrl = "https://img0.baidu.com/it/u=3305465566,3693572979&fm=253&app=138&f=JPEG?w=1067&h=800",
                    Amenity = "",
                    CreatedDate = DateTime.Now
                },
                new Villa()
                {
                    Id = 5,
                    Name = "Diamond Pool Villa",
                    Details = "This is the Diamond Pool Villa",
                    Rate = 600.0,
                    Sqft = 1100,
                    Occupancy = 4,
                    ImageUrl = "https://img0.baidu.com/it/u=521016149,2660609017&fm=253&app=138&f=JPEG?w=1067&h=800",
                    Amenity = "",
                    CreatedDate = DateTime.Now
                }
                );
        }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
            // 开发期间可忽略模型未迁移的警告
            optionsBuilder.ConfigureWarnings(warnings => warnings.Ignore(RelationalEventId.PendingModelChangesWarning));
        }
    }
}
